import pygame
from pygame.locals import *
import random
    
    
class Star:
    
    x = None
    y = None
    speed = None
    
    def __init__(self,x,y,speed):
        self.x = x
        self.y = y
        self.speed = speed
        
        
        
        
def run():
    pygame.init()
    screen = pygame.display.set_mode((640, 480), FULLSCREEN)
    
    ### lets create some start
    stars = [] 
    clock = pygame.time.Clock()
    
    a = 0
    while a < 100:
        a = a + 1
        s = Star(random.randint(0,639), random.randint(0,479),random.randint(10,300))
        stars.append(s)
        
        
        
        
    while True:
        
        for event in pygame.event.get():
            if event.type == QUIT:
                return
        if event.type == KEYDOWN:
                return
            
        if ( len(stars) < 10000 ):
            s = Star(639,random.randint(0,479),random.randint(10,300))
            stars.append(s)
        
        def on_screen(star):
            return star.x > 0
        
        stars = list(filter(on_screen, stars))
        screen.fill((0,0,0))
        white = (255,255,255)
        
        time_passed = clock.tick()
        time_passed_seconds = time_passed / 1000.
    
        
        for star in stars:
            new_x = star.x - time_passed_seconds * star.speed
            pygame.draw.aaline(screen, white, (new_x, star.y), (star.x+1., star.y))
            star.x = new_x
        
        pygame.display.update()
        
    
if __name__ == "__main__":
    run()        